//
//  NormalShopTableViewCell.m
//  Shengzhuli
//
//  Created by 卡忙科技 on 16/7/26.
//  Copyright © 2016年 kamangkeji. All rights reserved.
//

#import "NormalShopTableViewCell.h"
#import <UIImageView+WebCache.h>

@interface NormalShopTableViewCell()

@property (weak, nonatomic) IBOutlet UIImageView *thumbnailImageView;
@property (weak, nonatomic) IBOutlet UILabel *goodsNameLab;
@property (weak, nonatomic) IBOutlet UILabel *priceLab;
@property (weak, nonatomic) IBOutlet UILabel *distanceLab;
@property (weak, nonatomic) IBOutlet UIView *starView;

@end
@implementation NormalShopTableViewCell
- (void)awakeFromNib {
    [super awakeFromNib];
    for (NSInteger i=0; i<5; i++) {
        UIImageView *starImage = [[UIImageView alloc]initWithFrame:CGRectMake(20*i, 0, 20, 20)];
        starImage.image = [UIImage imageNamed:@"star_bai"];
        [self.starView addSubview:starImage];
    }
}
- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated
{
    if (highlighted) {
        self.backgroundColor = [UIColor lightGrayColor];
    }else{
        self.backgroundColor = [UIColor whiteColor];
    }
    [super setHighlighted:highlighted animated:animated];
}

- (void)setModel:(NormalShopGoodsModel *)model
{
    _model = model;
    [self.thumbnailImageView sd_setImageWithURL:[NSURL URLWithString:model.thumbnailUrl] placeholderImage:GetImage(@"default_goods_image")];
    self.goodsNameLab.text = model.name;
    self.priceLab.text = [NSString stringWithFormat:@"¥%.2f",model.price];
    self.distanceLab.text = model.distance;
    
    for (NSInteger i=0; i<5; i++) {
        UIImageView *starImage = self.starView.subviews[i];
        if (model.avgStartLevel<i+1) {
            starImage.image = [UIImage imageNamed:@"star_bai"];
        }else{
            starImage.image = [UIImage imageNamed:@"star_huang"];
        }
    }
}

@end
